from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, Email, EqualTo
from wtforms import BooleanField
from wtforms import IntegerField

class BorrowBookForm(FlaskForm):
    borrower_username = StringField('借阅者姓名', validators=[DataRequired()])
    submit = SubmitField('确定')
class BorrowerForm(FlaskForm):
    name = StringField('姓名', validators=[DataRequired()])
    contact = StringField('联系方式', validators=[DataRequired()])
    books_borrowed = IntegerField('已借图书数量')
    submit = SubmitField('确定')
class BookForm(FlaskForm):
    title=StringField('书名',validators=[DataRequired()])
    author=StringField('作者',validators=[DataRequired()])
    available=BooleanField('是否可借')
    submit=SubmitField('确定')
    borrower_username = StringField('借阅者姓名', validators=[DataRequired()])
    submit = SubmitField('确定')

# 定义用户注册表单类
class RegistrationForm(FlaskForm):
    # 用户名字段，验证器确保输入内容不为空
    username = StringField('用户名', validators=[DataRequired()])
    # 电子邮件字段，验证器确保输入内容不为空且格式为电子邮件
    email = StringField('邮箱', validators=[DataRequired(), Email()])
    # 密码字段，验证器确保输入内容不为空
    password = PasswordField('密码', validators=[DataRequired()])
    # 确认密码字段，验证器确保输入内容不为空且与密码字段匹配
    confirm_password = PasswordField('确认密码', validators=[DataRequired(),
    EqualTo('password')])
    # 提交按钮
    submit = SubmitField('注册')


# 定义用户登录表单类
class LoginForm(FlaskForm):
    # 电子邮件字段，验证器确保输入内容不为空且格式为电子邮件
    email = StringField('邮箱', validators=[DataRequired(), Email()])
    # 密码字段，验证器确保输入内容不为空
    password = PasswordField('密码', validators=[DataRequired()])
    # 提交按钮
    submit = SubmitField('登录')